package top.easyblog.core.dao.auto.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
import top.easyblog.core.dao.auto.model.MappingVisitRecord;
import top.easyblog.core.dao.auto.model.MappingVisitRecordExample;

@Mapper
@Repository
public interface MappingVisitRecordMapper {
    @SelectProvider(type=MappingVisitRecordSqlProvider.class, method="countByExample")
    long countByExample(MappingVisitRecordExample example);

    @DeleteProvider(type=MappingVisitRecordSqlProvider.class, method="deleteByExample")
    int deleteByExample(MappingVisitRecordExample example);

    @Delete({
        "delete from mapping_visit_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into mapping_visit_record (unique_identity, client_ip, ",
        "user_agent, referer, ",
        "short_url, long_url, ",
        "short_url_digest, long_url_digest, ",
        "compression_code, phone_type, ",
        "browser_type, browser_version, ",
        "os_type, device_type, ",
        "os_version, transform_status, ",
        "create_time, update_time, ",
        "deleted)",
        "values (#{uniqueIdentity,jdbcType=VARCHAR}, #{clientIp,jdbcType=VARCHAR}, ",
        "#{userAgent,jdbcType=VARCHAR}, #{referer,jdbcType=VARCHAR}, ",
        "#{shortUrl,jdbcType=VARCHAR}, #{longUrl,jdbcType=VARCHAR}, ",
        "#{shortUrlDigest,jdbcType=VARCHAR}, #{longUrlDigest,jdbcType=VARCHAR}, ",
        "#{compressionCode,jdbcType=VARCHAR}, #{phoneType,jdbcType=VARCHAR}, ",
        "#{browserType,jdbcType=VARCHAR}, #{browserVersion,jdbcType=VARCHAR}, ",
        "#{osType,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR}, ",
        "#{osVersion,jdbcType=VARCHAR}, #{transformStatus,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{deleted,jdbcType=BIT})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(MappingVisitRecord record);

    @InsertProvider(type=MappingVisitRecordSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(MappingVisitRecord record);

    @SelectProvider(type=MappingVisitRecordSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="unique_identity", property="uniqueIdentity", jdbcType=JdbcType.VARCHAR),
        @Result(column="client_ip", property="clientIp", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_agent", property="userAgent", jdbcType=JdbcType.VARCHAR),
        @Result(column="referer", property="referer", jdbcType=JdbcType.VARCHAR),
        @Result(column="short_url", property="shortUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="long_url", property="longUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="short_url_digest", property="shortUrlDigest", jdbcType=JdbcType.VARCHAR),
        @Result(column="long_url_digest", property="longUrlDigest", jdbcType=JdbcType.VARCHAR),
        @Result(column="compression_code", property="compressionCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone_type", property="phoneType", jdbcType=JdbcType.VARCHAR),
        @Result(column="browser_type", property="browserType", jdbcType=JdbcType.VARCHAR),
        @Result(column="browser_version", property="browserVersion", jdbcType=JdbcType.VARCHAR),
        @Result(column="os_type", property="osType", jdbcType=JdbcType.VARCHAR),
        @Result(column="device_type", property="deviceType", jdbcType=JdbcType.VARCHAR),
        @Result(column="os_version", property="osVersion", jdbcType=JdbcType.VARCHAR),
        @Result(column="transform_status", property="transformStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT)
    })
    List<MappingVisitRecord> selectByExample(MappingVisitRecordExample example);

    @Select({
        "select",
        "id, unique_identity, client_ip, user_agent, referer, short_url, long_url, short_url_digest, ",
        "long_url_digest, compression_code, phone_type, browser_type, browser_version, ",
        "os_type, device_type, os_version, transform_status, create_time, update_time, ",
        "deleted",
        "from mapping_visit_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="unique_identity", property="uniqueIdentity", jdbcType=JdbcType.VARCHAR),
        @Result(column="client_ip", property="clientIp", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_agent", property="userAgent", jdbcType=JdbcType.VARCHAR),
        @Result(column="referer", property="referer", jdbcType=JdbcType.VARCHAR),
        @Result(column="short_url", property="shortUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="long_url", property="longUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="short_url_digest", property="shortUrlDigest", jdbcType=JdbcType.VARCHAR),
        @Result(column="long_url_digest", property="longUrlDigest", jdbcType=JdbcType.VARCHAR),
        @Result(column="compression_code", property="compressionCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone_type", property="phoneType", jdbcType=JdbcType.VARCHAR),
        @Result(column="browser_type", property="browserType", jdbcType=JdbcType.VARCHAR),
        @Result(column="browser_version", property="browserVersion", jdbcType=JdbcType.VARCHAR),
        @Result(column="os_type", property="osType", jdbcType=JdbcType.VARCHAR),
        @Result(column="device_type", property="deviceType", jdbcType=JdbcType.VARCHAR),
        @Result(column="os_version", property="osVersion", jdbcType=JdbcType.VARCHAR),
        @Result(column="transform_status", property="transformStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT)
    })
    MappingVisitRecord selectByPrimaryKey(Long id);

    @UpdateProvider(type=MappingVisitRecordSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") MappingVisitRecord record, @Param("example") MappingVisitRecordExample example);

    @UpdateProvider(type=MappingVisitRecordSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") MappingVisitRecord record, @Param("example") MappingVisitRecordExample example);

    @UpdateProvider(type=MappingVisitRecordSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MappingVisitRecord record);

    @Update({
        "update mapping_visit_record",
        "set unique_identity = #{uniqueIdentity,jdbcType=VARCHAR},",
          "client_ip = #{clientIp,jdbcType=VARCHAR},",
          "user_agent = #{userAgent,jdbcType=VARCHAR},",
          "referer = #{referer,jdbcType=VARCHAR},",
          "short_url = #{shortUrl,jdbcType=VARCHAR},",
          "long_url = #{longUrl,jdbcType=VARCHAR},",
          "short_url_digest = #{shortUrlDigest,jdbcType=VARCHAR},",
          "long_url_digest = #{longUrlDigest,jdbcType=VARCHAR},",
          "compression_code = #{compressionCode,jdbcType=VARCHAR},",
          "phone_type = #{phoneType,jdbcType=VARCHAR},",
          "browser_type = #{browserType,jdbcType=VARCHAR},",
          "browser_version = #{browserVersion,jdbcType=VARCHAR},",
          "os_type = #{osType,jdbcType=VARCHAR},",
          "device_type = #{deviceType,jdbcType=VARCHAR},",
          "os_version = #{osVersion,jdbcType=VARCHAR},",
          "transform_status = #{transformStatus,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "deleted = #{deleted,jdbcType=BIT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MappingVisitRecord record);
}